package cn.fotoit.product.util;


import lombok.Data;

/**
 * 服务器基本响应对象
 */
@Data
public class ReturnBean {


    private String msg;

    private Object obj;

    private boolean isOk;

    private Object ext;

    private ReturnBean() {
    }

    private ReturnBean(String msg, Object data, boolean isOk, Object ext) {
        this.msg = msg;
        this.obj = data;
        this.ext = ext;
        this.isOk = isOk;
    }


    public static ReturnBean success(String msg, Object data, Object ext) {
        return new ReturnBean(msg, data, true, ext);
    }

    public static ReturnBean success(String msg, Object data) {
        return new ReturnBean(msg, data, true, null);
    }

    public static ReturnBean success(String msg) {
        return new ReturnBean(msg, null, true, null);
    }

    public static ReturnBean success() {
        return new ReturnBean("成功", null, true, null);
    }

    public static ReturnBean error(String msg, Object obj) {
        return new ReturnBean(msg, obj, false, null);
    }

    public static ReturnBean error(String msg) {
        return new ReturnBean(msg, null, false, null);
    }


}
